<template>
  <div class="liquid">
    <div class="liquid-content">
      <div
        v-for="(item, key) in list"
        :key="key"
        class="liquid-content-item"
        :style="{}"
      >
        <el-tooltip
          class="item"
          effect="dark"
          content="指数信息"
          placement="bottom"
        >
          <div class="wave" :style="{borderColor: getScore(item.proportion)}">
            <span>{{ item.proportion }}</span>
            <div class="wave1" :style="{top: 100 - item.proportion + '%', background: getScore(item.proportion)}" />
            <div class="wave2" :style="{top: 100 - item.proportion + '%', background: getScore(item.proportion)}" />
            <div class="wave3" :style="{top: 100 - item.proportion + '%', background: getScore(item.proportion)}" />
          </div>
        </el-tooltip>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';

const list = ref([{
  proportion: 40,
}, {
  proportion: 70,
}, {
  proportion: 88,
}, {
  proportion: 92,
}]);

// 获取颜色值
const getScore = (val: number) =>{
  let color = '';
  if (val >= 90) {
    color = '#ff3333';
  } else if (val >= 80) {
    color = '#FF9933';
  } else if (val >= 60) {
    color = '#FFAA00';
  } else {
    color = '#339900';
  }
  return color;
};
</script>

<style lang="scss" scoped>
.liquid {
  width: 100%;
  height: 100%;
  text-align: center;
  &-content {
    width: 100%;
    display: flex;
    align-items:center;
    justify-content: center;
    &-item {
      width: 80px;
      height: 80px;
      font-size: 18px;
      line-height: 60px;
      text-align: center;
      cursor: pointer;
      background-size: 100% 100%;
      margin: 100px 100px;
      float: left;
      .wave{
        position: relative;
        border: 1px solid silver;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        line-height: 80px;
        margin: 0 auto;

        text-align: center;
        overflow: hidden;
        animation: water-wave linear infinite;
        position: relative;
        span {
          display: inline-block;
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          line-height: 80px;
          text-align: center;
          z-index: 10;
          color: #666;
          font-size: 16px;
        }
      }
      .wave1{
        position: absolute;
        top: 40%;
        left: -25%;
        opacity: .7;
        width: 200%;
        height: 200%;
        border-radius: 40%;
        animation: inherit;
        animation-duration: 5s;
      }
      .wave2{
        position: absolute;
        top: 40%;
        left: -35%;
        opacity: .7;
        width: 200%;
        height: 200%;
        border-radius: 35%;
        animation: inherit;
        animation-duration: 7s;
      }
      .wave3{
        position: absolute;
        top: 40%;
        left: -45%;
        opacity: .3;
        width: 200%;
        height: 200%;
        border-radius: 40%;
        animation: inherit;
        animation-duration: 11s;
      }
      @keyframes  water-wave{
        0% {transform: rotate(0deg);}
        100% {transform: rotate(360deg);}
      }
    }
  }
}

</style>
